<template>
    <el-dialog v-model="store.state.dialogVisible" title="修改数值" width="30%" :close="cancel">
        <el-input-number v-model="num" />
        <template #footer>
            <span class="dialog-footer">
                <el-button @click="cancel">取消</el-button>
                <el-button type="primary" @click="confirm">
                    保存
                </el-button>
            </span>
        </template>
    </el-dialog>
</template>

<script lang="ts" setup>
    import { ref,watch } from 'vue'
    import { useStore } from 'vuex'
    import { key } from '../store'
    const store = useStore(key)
    let num = ref<number>(store.state.num)
    watch(():number => store.state.activeIndex, () => {
        num.value = store.state.num
    })
    const confirm = ():void => {
        store.commit('cancel', { flag: true, num:num.value })
    }
    const cancel = ():void => {
        store.commit('cancel', { flag: false })
    }
</script>

<style>

</style>